<template>
  <div class="true-or-false topic_item">
    <div class="topic">
      <span class="order">{{ topic.order || "" }}.&nbsp;</span>
      <div class="stem">
        <span style="color: #a8a8b3">(判断题)</span>{{ topic.title }}
      </div>
      <div class="judge-erea">
        <el-radio-group v-model="judgeRes">
          <el-radio-button :disabled="disabled" label="是"></el-radio-button>
          <el-radio-button :disabled="disabled" label="否"></el-radio-button>
        </el-radio-group>
      </div>
    </div>
    <answer-explain
      v-if="type == 3"
      :reviewResult="reviewResult"
    ></answer-explain>
  </div>
</template>

<script>
// 逻辑结构：题号. 命题 单选框（yes or no）
import AnswerExplain from "@/components/AnswerExplain.vue";

export default {
  props: ["topic", "finish", "answer", "type", "reviewResult"],
  data() {
    return {
      judgeRes: "",
    };
  },
  components: {
    AnswerExplain,
  },
  watch: {
    judgeRes() {
      this.finish(this.topic.order - 1, this.judgeRes);
    },
  },
  computed: {
    disabled() {
      return this.type == 2 || this.type == 3;
    },
  },
  mounted() {
    if (this.answer) {
      this.judgeRes = this.answer;
    }
  },
};
</script>

<style lang='less' scoped>
.true-or-false {
  // display: flex;
  .topic {
    display: flex;
    flex-direction: row;
  }
  // height: 40px;
  span {
    line-height: 40px;
  }
  .judge-erea {
    margin-left: 20px;
  }
}
</style>